﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Prism.WebBuilder.Lib.Cui
{
	public static class Cui
	{
		private static int _indent = 0;

		public static IDisposable BeginIndent()
		{
			IncreaseIndent();
			return new CuiIndenter();
		}

		public static void IncreaseIndent()
		{
			_indent ++;
		}

		public static void DecreaseIndent()
		{
			_indent--;
		}
		
		public static void Error(string format, params object []args)
		{
			Console.WriteLine(IndentText()+string.Format("Error: "+format, args));
		}

		public static void Info(string format, params object[] args)
		{
			Console.WriteLine(IndentText()+string.Format(format, args));
		}

		private static string IndentText()
		{
			return new string(' ', _indent*4);
		}


		private sealed  class CuiIndenter:IDisposable
		{
			public void Dispose()
			{
				Cui.DecreaseIndent();
			}
		}
	}

	
}
